package com.itheima03;

import java.util.HashMap;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数据:");
        String line = sc.nextLine();


        HashMap<Character, Integer> hm = new HashMap<>();


        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);

            if (hm.containsKey(c)) {
                Integer count = hm.get(c);
                count++;
                hm.put(c, count);
            } else {
                hm.put(c, 1);
            }
        }
        hm.forEach((key, value) -> System.out.println("字符:" + key + "出现了:" + value));
    }
}
